#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2019/8/26 16:50
# @Author  : yangdy
# @Email   : yangdy@egu360.com
# @File    : 反转字符串中的元音字母.py
# @Software: PyCharm

__author__ = 'yangdy'


class Solution:
    def reverseVowels(self, s: str) -> str:
        aeiou = 'aeiouAEIOU'
        ret = s[:]
        i, j, l = 0, len(s)-1, len(s)
        while i < j:
            while i < l and s[i] not in aeiou:
                i += 1
            while j >= 0 and s[j] not in aeiou:
                j -= 1
            print(i, j)
            if i < j:
                ret = ret[:i] + ret[j] + ret[i+1:j] + ret[i] + ret[j+1:]
                print(ret)
                i, j = i+1, j-1
                print(i, j)
            else:
                break
        return ret


solve = Solution()

question = 'A man, a plan, a canal: Panama'
print('question:', question)
print(solve.reverseVowels(question))
